//
//  NetHelper.m
//  BCProjectB
//
//  Created by lanou3g on 15/12/16.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "NetHelper.h"
#import "AFNetworking.h"
static NetHelper *helper =nil;
@implementation NetHelper

+(instancetype)shareHelpers{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        helper=[[NetHelper alloc]init];
    });
    return helper;
}

-(void)getDataWithUrlStr:(NSString *)str whenSucess:(void (^)(id))SuceessBlock whenErr:(void (^)(NSError *))Err{
    AFHTTPSessionManager *manger=[AFHTTPSessionManager manager];
    if (!str) {
        return;
    }
   
   manger.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"application/x-javascript", nil];
        [manger GET:str parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"%@",responseObject);
        SuceessBlock(responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"%@",error);
    }];
    
    
    
    
//    [manger GET:url parameters:nil success:^(NSURLSessionTask *task, id responseObject) {
//        NSLog(@"JSON: %@", responseObject);
//    } failure:^(NSURLSessionTask *operation, NSError *error) {
//        NSLog(@"Error: %@", error);
//    }];
    
//    [manger GET:url.absoluteString parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//        NSLog(@"%@",downloadProgress);
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSLog(@"%@",responseObject);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        
//    }];
    
}







@end
